package com.yanglanting.disk.file.service.impl;

        import com.obs.services.ObsClient;
        import com.obs.services.exception.ObsException;
        import com.yanglanting.disk.file.entity.SearchFileEntity;
        import com.yanglanting.disk.file.repository.FileDao;
        import com.yanglanting.disk.file.service.FileService;
        import com.yanglanting.disk.mybatis.entity.PtFileEntity;
        import com.yanglanting.disk.mybatis.entity.PtRoleEntity;
        import com.yanglanting.disk.mybatis.entity.PtUserEntity;
        import com.yanglanting.disk.mybatis.flexigrid.PagingEntity;
        import com.yanglanting.disk.mybatis.flexigrid.TblResponseEntity;
        import org.springframework.stereotype.Service;

        import java.io.ByteArrayInputStream;
        import java.io.InputStream;
        import java.util.List;

        import javax.annotation.Resource;
        import java.util.List;

@Service
public class FileServiceImpl implements FileService {
    @Resource
    private FileDao fileDao;

    @Override
    public void saveFileInfo(List<PtFileEntity> ptFileEntityList) {
        fileDao.deleteFileAll();
        fileDao.saveFileInfo(ptFileEntityList);
    }

    @Override
    public TblResponseEntity<PtFileEntity> queryFileInfoListByPage(SearchFileEntity entity, PagingEntity paging) {

        TblResponseEntity<PtFileEntity> tblResponseEntity = new TblResponseEntity<>();
        Integer total = fileDao.queryFileListTotal(entity);
        tblResponseEntity.setTotal(total);
        //计算当前页数
        paging.deal(PtFileEntity.class, total);
        tblResponseEntity.setPage(paging.getPage());

        List<PtFileEntity> list = fileDao.queryFileInfoListByPage(entity, paging);
        tblResponseEntity.setRawRecords(list);

        tblResponseEntity.deal();

        return tblResponseEntity;
    }

    @Override
    public PtFileEntity queryFileInfoById(String fileUuid) {

        return fileDao.queryFileInfoById(fileUuid);
    }

    @Override
    public List<PtFileEntity> queryFileListAll() {

        return fileDao.queryFileListAll();
    }


    /**
     * yang
     **/
    @Override
    public void modifyFileInfoById(PtFileEntity entity) {
        fileDao.modifyFileInfoById(entity);
    }

    /**
     * yang
     **/


    @Override
    public void deleteFileToRecycle(String fileUuid) {
        fileDao.updateFileToRecycle(fileUuid);
    }

}
